package com.wiz.data.vo.to;



/**
 * long数字域
 * @author Hakeny
 */
public class MessageLongFiled extends MessageFiled {

	@Override
	public byte[] toBytes() {
		long longValue = ((Long)value).longValue();
		byte[] b = new byte[8]; 
        for (int i = 0; i < b.length; i++) { 
            b[i] = new Long(longValue & 0xff).byteValue();// 将最低位保存在最低位 
            longValue = longValue >> 8; // 向右移8位 
        }
		return b;
	}

	@Override
	protected Object clone() throws CloneNotSupportedException {
		MessageLongFiled filed = (MessageLongFiled) super.clone();
		filed.setType(this.type);
//		filed.setValue(this.value);
		filed.setNeedLength(this.needLength);
		return filed;
	}
	
	public static void main(String[] args) {
		long temp = System.currentTimeMillis();
		System.out.println(temp);
		byte[] b = new byte[8]; 
        for (int i = 0; i < b.length; i++) { 
            b[i] = new Long(temp & 0xff).byteValue();// 将最低位保存在最低位 
            temp = temp >> 8; // 向右移8位 
        }
        
        long s = 0; 
        long s0 = b[0] & 0xff;// 最低位 
        long s1 = b[1] & 0xff; 
        long s2 = b[2] & 0xff; 
        long s3 = b[3] & 0xff; 
        long s4 = b[4] & 0xff;// 最低位 
        long s5 = b[5] & 0xff; 
        long s6 = b[6] & 0xff; 
        long s7 = b[7] & 0xff; 
 
        // s0不变 
        s1 <<= 8; 
        s2 <<= 16; 
        s3 <<= 24; 
        s4 <<= 8 * 4; 
        s5 <<= 8 * 5; 
        s6 <<= 8 * 6; 
        s7 <<= 8 * 7; 
        s = s0 | s1 | s2 | s3 | s4 | s5 | s6 | s7; 
        System.out.println(s);
	}
}
